%This file aims to create a list of sample markets for bootstraping

clear
tic
nboots=200; %set # bootstraps


%&&& Prepare for the list of markets in each bootstrap
textFileName_lmkt=sprintf('list_mkt.csv'); %the input file
list_mkt=dlmread(textFileName_lmkt); %matrix: [hsa, nhosp]

rng(0);
seed_candidates=randsample(1:10000,nboots);  %create the list of seeds, WITHOUT replacement
%rsmpl=zeros(size(list_mkt,1),nboots);
for i=1:nboots
    j=seed_candidates(i);
    rng(j);  
    rsmpl=sort(randsample(list_mkt(:,1),size(list_mkt,1),true));  %NOT use the weight in terms of "nhosp"
    %rsmpl(:,i)=sort(randsample(list_mkt(:,1),size(list_mkt,1),true,list_mkt(:,2)));
    textFileName_mkt=sprintf('smplmkt%d.csv',i);
    dlmwrite(textFileName_mkt,rsmpl,'delimiter', ',', 'precision', 8)
end

toc




